<!-- 设置 -->
<template>
	<view class="setting-container">
    <t-header @back="clickNavBackFn">设置</t-header>
		<!-- content -->
		<view class="setting-content">
			<view class="setting-c-content">
				<view class="setting-c-c-cell" @click="toInfo">
					<view class="setting-c-c-l">个人信息</view>
					<tui-icon name="arrowright" :size="20" color="#A8A8A8"></tui-icon>
				</view>
				<view class="setting-c-c-cell">
					<view class="setting-c-c-l">检查更新</view>
					<view class="setting-c-c-r">
						<view>当前版本8.8.9</view>
						<tui-icon name="arrowright" :size="20" color="#A8A8A8"></tui-icon>
					</view>
				</view>
				<view class="setting-c-c-cell">
					<view class="setting-c-c-l">个人信息</view>
					<view class="setting-c-c-r">
						<view>45MB</view>
						<tui-icon name="arrowright" :size="20" color="#A8A8A8"></tui-icon>
					</view>
				</view>
			</view>
			<button @click="showLogut=true" class="setting-c-btn">退出登录</button>
			
			<tui-actionsheet
				color="#e53a37"
				:show="showLogut"
				tips="确定要退出吗？"
				@click="onOutTap"
				@cancel="showLogut=false"
			/>
		</view>
	</view>
</template>

<script setup>
import {ref} from 'vue';

import THeader from '@/components/views/t-header/index.vue'; // 头部组件

// store
import {useUserStore} from '@/store/user.js';
// user
const userStore = useUserStore();

// 点击返回
const clickNavBackFn = () => {
	const pages = getCurrentPages();
	if (pages.length >= 2) {
		uni.navigateBack();
	} else {
		uni.switchTab({
			url: '/pages/my/index'
		});
	}
};

const toInfo = () => {
	uni.navigateTo({
		url: '/pages/setting/userInfo'
	})
};

const showLogut = ref(false);

const onOutTap = () => {
	// 清空之前获取下
	let account = uni.getStorageSync('account')
	let password = uni.getStorageSync('password')
	let ssss = uni.getStorageSync('ssss')
	let curr_api_line_index = uni.getStorageSync('curr_api_line_index')
	let curr_api_url = uni.getStorageSync('curr_api_url')
	uni.clearStorageSync();
	// uni.removeStorageSync('token');
	uni.setStorageSync('account', account)
	uni.setStorageSync('password', password)
	uni.setStorageSync('ssss', ssss)
	uni.setStorageSync('curr_api_url', curr_api_url)
	uni.setStorageSync('curr_api_line_index', curr_api_line_index)
	userStore.setUser(null);
	uni.reLaunch({
		url: '/pages/login/index'
	});
};
</script>

<style lang='scss' scoped>
.setting-container {
	display: flex;
	flex-direction: column;
	width: 100vw;
	height: 100vh;
	background: #F5F5F5;
	box-sizing: border-box;

	.setting-content {
		flex: 1;
		display: flex;
		flex-direction: column;
		align-items: center;
		padding: 0 18rpx 26rpx;
		
		.setting-c-content {
			width: 100%;
			height: 348rpx;
			padding: 34rpx 58rpx 34rpx 50rpx;
			border-radius: 34rpx;
			background: #FFFFFF;
			box-sizing: border-box;
			
			.setting-c-c-cell {
				display: flex;
				justify-content: space-between;
				align-items: center;
				width: 100%;
				
				&:not(:last-child) {
					margin-bottom: 32rpx;
					padding-bottom: 36rpx;
					border-bottom: 2rpx solid #E2E2E2;
				}
				
				.setting-c-c-l {
					color: #373737;
					font-size: 32rpx;
					font-weight: 400;
					font-family: PingFangSC, PingFang SC;
				}
				
				.setting-c-c-r {
					display: flex;
					align-items: center;
					color: #B1B1B1;
					font-size: 32rpx;
					font-weight: 400;
					font-family: PingFangSC, PingFang SC;
				}
			}
		}
		
		.setting-c-btn {
			display: flex;
			justify-content: center;
			align-items: center;
			width: 674rpx;
			height: 96rpx;
			margin-top: 54rpx;
			border-radius: 62rpx;
			background: linear-gradient( 178deg, #FF7E3E 0%, #F62645 100%);
			color: #FFFFFF;
			font-size: 32rpx;
			font-weight: 400;
			font-family: PingFangSC, PingFang SC;
		}
	}
}
</style>
